package com.caishi.lkx.course.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.caishi.lkx.exam.model.FreeModel;
import com.zzw.common.entity.impl.BaseEntity;
import com.zzw.common.service.model.base.BaseTreeModelV2;
import com.zzw.common.service.model.base.SortModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.util.List;


@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "kc_video_chapter", autoResultMap = true)
@Schema(title = "视频章节")
public class VideoChapterModel extends BaseEntity<VideoChapterModel> implements BaseTreeModelV2<VideoChapterModel, String>,
        SortModel<VideoChapterModel>,
        FreeModel<VideoChapterModel> {
    /**
     * 科目名称
     */
    private String name;

    /**
     * 后台显示名称
     */
    private String serverName;

    /**
     * 上级科目
     */
    private String parentId;

    private String path;

    @Schema(title = "叶子节点标志")
    private Boolean leaf;

    /**
     * 所属科目id
     */
    private Long categoryId;

    /**
     * 排序
     */
    private Integer sort;

    //视频数
    private Integer videoNum;

    /**
     * 备注
     */
    private String remark;

    @TableField(exist = false)
    private VideoChapterModel parent;

    @TableField(exist = false)
    private List<VideoChapterModel> children;

    @TableField(value = "video_ids", typeHandler = JacksonTypeHandler.class)
    private List<String> videoIds;

    @Schema(title = "免费标志 true 免费，false 收费")
    @TableField(exist = false)
    private Boolean free;

    @Schema(title = "观看视频数量")
    @TableField(exist = false)
    private Integer watchNum;

    @Override
    public int hashCode() {
        return getId().hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof VideoChapterModel gr) return gr.getId().equals(this.getId());
        return super.equals(obj);
    }

    @Override
    public String idCover(String strId) {
        return strId;
    }





}
